package com.jtjrenren.android.taxi.driver.manger.task;

import android.content.Context;

import com.jtjrenren.android.taxi.driver.bean.Order;
import com.jtjrenren.android.taxi.driver.bean.event.CommonEvent;



import org.greenrobot.eventbus.EventBus;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2016/5/24.
 */
public class CheckYydTask implements Runnable {
    private static final long TIME_YYD_CHECK = 10 * 60 * 1000;
    private Context context;

    public CheckYydTask(Context context) {
        this.context = context;
    }

    @Override
    public void run() {
        long current = System.currentTimeMillis();
        ArrayList<Order> orderListNotFinishYYD = new ArrayList<>();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyMMddHHmmss");
        String useDate;
        long sjc = 0;
        for (Order info : orderListNotFinishYYD) {
            useDate = info.getUseDate();
            try {
                sjc = simpleDateFormat.parse(useDate).getTime();
            } catch (ParseException e) {
                e.printStackTrace();
            }
            long jg = sjc - current;
            if (jg < TIME_YYD_CHECK && jg > 0) {
                Map<String, Object> values = new HashMap<>();
                values.put("order", info);
                EventBus.getDefault().post(new CommonEvent(CommonEvent.MODE_YYD_TX, values));
                break;
            }
        }
    }
}
